'''
Created on Apr 28, 2011

@author: All

user-defined exceptions are put here
'''

class ErrorMessage:
    token_invalid = "Your token is invalid"
    logout = "Failed to logout"
    login = "Failed to login"
    permission = "You have no permission to read this voucher"
    receive = "You have no permission to receive this voucher"
    voucher_create = "Failed to create voucher"
    voucher_modify = "Failed to modify voucher"
    voucher_status_update = "Failed to update voucher status"
    voucher_consume_type = "Wrong voucher consume type"
    voucher_date_type = "Wrong voucher date type"
    file_upload = "Upload file failed"
    
class ServerError(Exception):
    # define basic emma exception
    def __init__(self, error_message, status_code = '1'):
        Exception.__init__(self, error_message)
        self.error_message = error_message
        self.status_code = status_code

class TokenInvalidError(ServerError):
    def __init__(self, error_message = ErrorMessage.token_invalid, status="2"):
        self.error_message = error_message
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message, self.status_code)

class LogoutError(ServerError):
    def __init__(self, error_message=ErrorMessage.logout, status = "1"):        
        self.error_message = error_message
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)
          
class LoginError(ServerError):
    def __init__(self, error_message=ErrorMessage.login, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)  
        
class VoucherPermissionError(ServerError):
    def __init__(self, error_message=ErrorMessage.permission, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message) 

class VoucherReceiveError(ServerError):
    def __init__(self, error_message=ErrorMessage.receive, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message) 

class VoucherCreationError(ServerError):
    def __init__(self, error_message=ErrorMessage.voucher_create, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message) 
      
class VoucherModifyError(ServerError):
    def __init__(self, error_message=ErrorMessage.voucher_modify, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)       
        
class VoucherStatusUpdateError(ServerError):
    def __init__(self, error_message=ErrorMessage.voucher_status_update, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message) 
        
class VoucherConsumeTypeError(ServerError):
    def __init__(self, error_message=ErrorMessage.voucher_consume_type, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message) 

class VoucherDateTypeError(ServerError):
    def __init__(self, error_message=ErrorMessage.voucher_date_type, status = "1"):        
        self.error_message = error_message        
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message) 


class SQLError(ServerError):
    def __init__(self, error_message="SQL Execute failed", status="1"):
        self.error_message = error_message
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)
        
        
class TransactionError(ServerError):
    def __init__(self, error_message="Mobile money transaction error", status="1"):
        self.error_message = error_message
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)
        
        
class TransactionOutofLoacationError(ServerError):
    def __init__(self, error_message="Mobile money transaction location out of range", status="1"):
        self.error_message = error_message
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)
        
class PinCodeNotMatchError(ServerError):
    def __init__(self, error_message="Pin Code not Match", status="1"):
        self.error_message = error_message
        self.status_code = status
        # Call Exception.__init__
        ServerError.__init__(self,self.error_message)

class FileUploadError(ServerError):
    def __init__(self, error_message=ErrorMessage.file_upload, status = "1"):
        ServerError.__init__(self,error_message, status)  
